﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="author" content="Sytech Designs Ltd"/>
<title>Getting Started with the NANO Kit for Microsoft .NET Gadgeteer</title>

<style type="text/css">
    body {
        background-color: #D7D7D7;
        font-family: Arial, Helvetica, sans-serif;
        font-size: smaller;
        line-height: 1.38em;
    }

    div.image {
        margin: 20px 0;
        text-align: center;
    }

    div.image div {
        color: #5D0000;
        font-size: 85%;
        margin: 8px 0;
    }

    em {
        color: #FF0000;
    }

    h1 {
        border-bottom: 1px solid #A0A0A0;
        color: #5D0000;
        font-size: 170%;
        padding-bottom: 5px;
    }

    h2 {
        color: #00008B;
        font-size: 150%;
    }

    h3 {
        color: #9C1F1F;
        font-size: 125%;
    }

    h4 {
        font-size: 105%;
    }

    img {
        border: 1px solid #E0E0E0;
    }

    li {
        margin-bottom: 8px;
        margin-top: 8px;
    }

    ol {
    }

    p {
        margin: 8px;
    }

    .code {
        color: #000000;
    }

    .code,
    .code-comment,
    .code-member,
    .code-keyword,
    .code-sample {
        font-family: "Courier New", Courier, monospace;
    }

    .code-comment {
        color: #008000;
    }

    .code-keyword {
        color: #0000FF;
    }

    .code-member {
        color: #008080;
    }

    .code-sample {
        margin: 12px 24px;
        font-size:100%;
        line-height: 1.15em;
    }

    .code-string {
        color: #B00000;
    }
    .important h3 {
        border-bottom: 1px solid #5D0000;
        color: #5D0000;
        margin: 0 0 12px 0;
        padding: 3px 0;
    }

    .important, .note {
        background-color: #FFFFE0;
        border: 1px solid #5D0000;
        margin: 20px 50px;
        padding: 0 12px 10px 12px;
    }

    .module {
        color: #000151;
        font-weight: bold;
    }

    .note {
        padding-top: 10px;
    }

    .red {
        color: #FF0000;
    }

    .ui {
        color: #00018A;
        font-weight: bold;
    }

    #main {
        background-color: #FFFFFF;
        border: 1px solid #A0A0A0;
        margin-left: auto;
        margin-right: auto;
        padding: 10px 20px;
        width: 880px;
    }
 </style>

</head>

<body>
<div id="main">
<h1>Getting Started with the NANO Development Kits for Microsoft .NET Gadgeteer</h1>

<p>
Welcome to the NANO Development kits from <a href="http://gadgeteerguy.com">
Sytech Designs</a>. The NANO mainboard and kits are compatible with
<a href="http://netmf.com/gadgeteer">Microsoft .NET Gadgeteer</a>. The NANO development kits enable 
you to quickly prototype and test functionality for embedded devices. 
This guide introduces you to the basic hardware components of the NANO range,
and shows how to create your first .NET Gadgeteer application
</p>

<p>
    .NET Gadgeteer development requires that you have Microsoft Visual Studio
 installed on your computer. You can use either of the following Visual Studio packages:
</p>

<ul>
 <li>
  <a href="http://www.microsoft.com/visualstudio/en-us/download" target="_new">Microsoft Visual Studio 2010</a> -
  This is the full featured Visual Studio application development suite with support for multiple
  programming languages.
 </li>

 <li>
  <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express" 
    target="_new">Microsoft Visual C# 2010 Express</a> -
  A free alternative, Visual C# 2010 Express provides lightweight, easy-to-learn and easy-to-use
  tools for creating applications.
 </li>
</ul>

<p>
This guide is organized into the following sections:
</p>



<ul>
<li><a href="#devenv">Setting up your Development Environment</a></li>
 <li><a href="#hardware">Building your First .NET Gadgeteer Device</a></li>
 <li><a href="#software">Creating Your First .NET Gadgeteer Application</a></li>
 <li><a href="#deployment">Deploying Your .NET Gadgeteer Application</a></li>
 <li><a href="#troubleshooting">Troubleshooting</a></li>
</ul>

<h2 id="devenv">Setting up your Development Environment</h2>
	<p>In addition to Visual Studio 2010, you need the following SDKs installed 
	on your PC. They are all free downloads.</p>
	<ul>
		<li>
		<a href="http://www.microsoft.com/download/en/details.aspx?id=8515" target="_blank">
		Micro Framework 4.1 QFE1 SDK</a></li>
		<li><a href="http://gadgeteer.codeplex.com/releases" target="_blank">
		Microsoft .NET Gadgeteer Core and Builder Templates</a></li>
		<li>
		<a href="http://gadgeteerguy.com/Downloads/tabid/144/Default.aspx" target="_blank">
		Meridian USB Drivers Install</a></li>
		<li>
		<a href="http://gadgeteerguy.com/Downloads/tabid/144/Default.aspx" target="_blank">
		NANO Gadgeteer Install SDK</a></li>
	</ul>
	<p>After Visual Studio is installed, you need to install the Micro Framework 
	SDK next. This will add the development environment for Microsoft .NET Micro 
	Framework to your Visual Studio installation.</p>
	<p>Next install the Microsoft .NET Gadgeteer Core and then the Gadgeteer 
	builder templates. This will add the gadgeteer environment to your installed 
	version of Visual Studio.</p>
	<p>To connect your NANO mainboard to your design environment over USB, you 
	need the USB drivers for the Meridian Module used on the NANO.</p>
	<p>These are auto installed using the Meridian USB Driver msi, avalaiable on 
	the GadgeteerGuy downloads page.32 bit and 64bit Windows USB Driver installs 
	are available here. Any required Device Solutions Meridian SDK files are installed with the NANO install package, you do not need the 
	Device Solutions SDK to use NANO.</p>
	<p>Lastly, you need to install the NANO Install SDK for .Net Gadgeteer. (or 
	the Sytech Gadgeteer Kit install, which includes the Nano and all modules)</p>
	<h3 id="usbtest">Test your NANO USB Driver Installation</h3>
	<p>We will now test that the NANO USB Drivers are installed correctly and 
	you can connect to the NANO using the USB Debug channel.</p>
	<p>First ensure that your NANO configuration switches are set to boot to 
	TinyCLR ( the normal setting for use) and that the debug channel is selected 
	as USB.</p>
	<p>Set Dip switches 3 and 4 to OFF to select Boot to TinyCLR.</p>
	<p>Set Dip switches 1 to OFF and Dip switch 2 to ON to select USB</p>
	<p>&nbsp;</p>
	<!-- Image: Mainboard Config Switches -->
	<div class="image">
	<img alt="NANO Configuration switches" title="NANO Configuration Switches"src="image001.jpg" />
	<div>NANO Configuration Switch Settings</div>
	</div>
	<p>
	
	Connect a <span class="module">USB Device and Power Supply Power (USBDevice)</span> module (colored <span class="red">red</span>) 
	to the <span class="module">NANO </span> mainboard socket 1 ( labelled D) using a cable.
	</p>
	<div class="important">
     <h3>Warning</h3>
       Never connect more than one <span class="red">red</span> module to the NANO 
       Mainboard at the same time. This could damage the hardware.</div>
       
       <div class="image">
       	<img alt="NANO with USBDevice" height="398" title="NANO with USBDevice" src="image002.jpg" width="581" />
       	<div>NANO with USB Device</div>
       	</div>
       	
     <div class="important">
 		<h3>Warning</h3>
   		 When plugging or unplugging any module into a NANO socket, always make 
        sure that <em>power is not connected</em>, by unplugging&nbsp; either end of the mini USB cable. 
        The mini USB cable supplies power to the NANO; if you plug or unplug a module on the NANO while
        it is powered, the hardware could be damaged. 
        If an External Power supply is connected, this must be switched off or disconnected as well.
     </div>

   <p>Connect a USB cable to the <span class="module">USB Device Module</span> and to your PC</p>
	<p>The NANO will power up and start the Micro Framework TinyCLR running.</p>
	<p>Start a copy of the Micro Framework tool <strong>MFDeploy.exe</strong></p>
	<p> You can find this at C:\Program Files\Microsoft .NET Micro Framework\v4.1\Tools\MFDeploy.exe</p>
	<p> Start the application and in the left hand combo box select <strong>USB</strong>. 
	The connected device id will be shown in the text box to the right</p>
	<div class="image">
	<img alt="MFDeploy" title="MFDeploy"src="image003.jpg" />
	<div>MFDeploy</div>
	</div>
	<p>If you press the <strong>Ping</strong> button, MFDeploy will 'ping' the device, over the debug connection. The 
	device will reply 'TinyCLR'</p>
	<p>Your USB debug connection is now tested and the USB drivers are 
	installed.</p>

	
	








<h2 id="hardware">Building your First .NET Gadgeteer Device</h2>
<p>The NANO Development kits contain a NANO mainboard, a number of hardware 
peripherals and sensor boards, which are called <i>modules</i> 
and cables to connect the modules to the mainboard</p>
<p>To create your embedded system, you simply plug in the modules, 
which supply the required functionality, to the mainboard</p>
<p>Our first project will be a very simple example of a push button switch and an LED. 
You will require the following parts:</p>
	<ul>
		<li>A NANO Mainboard</li>
		<li>A<span class="red"> RED</span><span class="module"> USB Device and 
		Power Supply</span> module.</li>
		<li>A <span class="module">Button</span> module.</li>
		<li>2 Module connector cables.</li>
	</ul>
	
	<h3>The NANO Mainboard</h3>
	<p>The NANO Mainboard has a 200Mhz ARM 9 processor, Flash and RAM memory, and a Touch Controller. 
	It also has 10 sockets. The sockets are outlined by a white box, with the socket number (<strong>1</strong>  
	through <strong>10</strong>) and function ID's inside the box. The function ID's are letters that define the 
	hardware capabilities of that socket. These ID's indicate which modules can be connected to the socket. </p>
	<p>.NET Gadgeteer compatible hardware modules connected to the NANO 
	Mainboard by these connectors allow you to create your custom embedded device.</p>
	<p>The NANO includes a hardware Reset button, configuration dip switch 
	block, a power led and a debug led.</p>
	<div class="image">
	<img alt="NANO Mainboard" title="NANO Mainboard"src="image004.jpg" />
	<div>NANO Mainboard</div>
	</div>
	<h3>The Module Connector Cable</h3>
	<p>IDC ribbon cables, of various lengths, are used to connect modules to mainboards. These cables have polarized connectors 
	and can only be plugged in one way ( the correct way!). All modules use the 
	same type of cable.</p>
	<div class="image">
	<img alt="Connection Cable" title="Connection cable"src="connector.png" />
	<div>A .NET Gadgeteer compatible Module connector cable</div>
	</div>

	<div class="important">
 		<h3>Warning</h3>
   		 When plugging or unplugging any module into a mainboard socket , always make 
        sure that <em>power is not connected</em>. If you plug or unplug a module on the NANO 
        (or any mainboard) while it is powered, the hardware could be damaged. 
      </div>

	<h3>USB Device and Power Supply Module</h3>
	<p>The <span class="module">USB Device and Power Supply </span>module ( colored
	<span class="red">red)</span> enables you to connect the NANO mainboard to your PC 
	and the development environment. It can be powered either from the USB port on the computer 
	or from an external +5V power supply. This module supplies the power for the mainboard and all
	the other modules connected. When an external power supply is connected, the USB power is protected,
	so you will not 'feed' power to your USB port on your computer.</p>
	<p>The module has a socket, the same as the sockets on the NANO mainboard. 
	The socket is marked with the letter<strong> D. This means this module can be connected to a 
	socket on the mainboard also labelled D.</strong></p>
	<p>In a similar way, all .NET Gadgeteer compatible modules have 
	letters next to their sockets that identify which mainboard sockets they can 
	be connected to. Some modules may have more than one letter next to their sockets. This
	means that they can be connected to any of the corresponding sockets on a mainboard.</p>
	<p>We connect our <span class="module">USB Device and Power Supply</span> 
	module to socket 1 on the NANO board.</p>
	<div class="image">
	<img alt="USB Device and Power Module" title="USB Device and Power Module"src="image005.jpg" />
	<div>USB Device and Power Module</div>
	</div>

   <h3>Button and LED Module</h3>
	<p>This is a very simple module and contains a push button switch and an 
	indicator LED. It requires a type<strong> X</strong>&nbsp; 
	mainboard socket. These support either 3 or 7 GPIO pins, the 
	<span class="module">Button</span> module just needs
	2 of the GPIO pins, one as an input the other as an output.</p>
	<p>For our example, we are going to connect the Button module to the NANO 
	socket 2. The NANO socket 2 supports <strong>Y</strong> (7 GPIO) , <strong>K</strong> 
	( serial port - no handshake) and <strong>U</strong> (Serial port with 
	handshake).Note a <strong>Y </strong>socket supports <strong>X</strong> by 
	default, as the <strong>Y</strong> definition contains all the pins of an
	<strong>X </strong>definition( 3 GPIO).</p>
	<div class="image">
	<img alt="Button Module" title="Button Module"src="image007.jpg" />
	<img alt="Button Module Connector" title="Button Module Connector"src="image006.jpg" height="143" width="182" />

	<div>Button Module and Connector</div>
	</div>
	 


	<p>We connect all the required modules to the NANO mainboard. For our example application we are going to 
	create all the code by hand. The Gadgeteer framework contains a Graphic 
	Designer add on to Visual Studio, that allows you to drag and drop 
	representations of the modules onto a design surface, and it will then help 
	you connect the modules and generate the code stubs for the application. We 
	will use this method in our second example.</p>
	<p>The following picture shows all the required modules connected to the NANO 
	mainboard.</p>
	<div class="image">
	<img alt="USB Device and Power Module" title="USB Device and Power Module"src="image008.jpg" />
	<div>Modules connected for our simple example</div>
	</div>


<h2 id="software">Creating Your First .NET Gadgeteer Application</h2>
	<p>Start <span class="ui">Microsoft Visual Studio 2010</span> or
	<span class="ui">Microsoft Visual C# 2010 Express.</span></p>
	<h3>To create a Visual Studio application:</h3>
	<ol>
		<li>On the <span class="ui">File</span> menu, select<span class="ui"> 
		New Project...</span>
		<div class="image">
			<img alt="Visual Studio" title="Visual Studio"src="image009.jpg" />
			<div>
				Microsoft Visual Studio</div>
		</div>
		</li>
		<li>
		On the 
		<span class="ui">New Project </span>screen, under <span class="ui">
		Installed Templates</span>, expand the <span class="ui">Visual C# </span>
		category</li>
		<li>
		Select<span class="ui"> Gadgeteer</span>.</li>
		<li>
		Select <span class="ui">.NET Gadgeteer Application</span>. Name the 
		project <span class="ui">Gadgeteer Button.</span></li>
		<li>
		Click <span class="ui">OK.</span>
		<div class="image">
			<img alt="Visual Studio Project" title="Visual Studio Project"src="image010.jpg" />
			<div>
				Microsoft Visual Studio .NET Gadgeteer Application Project</div>
		</div>
</li>		
	</ol>
	
	<h3>Using the .NET Gadgeteer Designer UI</h3>
	<p>The .NET Gadgeteer Designer opens with a mainboard displayed on the 
	canvas ( the first one it finds or the last one used). If the <strong>
	Toolbox </strong>is not visible, click the <span class="ui">View</span> menu 
	and select <span class="ui">Toolbox</span>. The Toolbox with a list of 
	installed Modules and Mainboards will open. You can resize or hide the
	<strong>Toolbox</strong> to make more space on the canvas.</p>
	<div class="image">
			<img alt="Gadgeteer Designer" title="Gadgeteer Designer"src="image011.jpg" />
			<div>
				Microsoft .NET Gadgeteer Application and Toolbox</div>
		</div>
		<p> If you want to use a different mainboard, open the toolbox, and 
		drag the mainboard icon of your choice onto the designer surface. the 
		following illustration shows the open toolbox with two mainboard 
		options.</p>
		<div class="image">
			<img alt="Gadgeteer Designer Mainboards" title="Gadgeteer Designer Mainboards"src="image012.jpg" />
			<div>
				Replace Mainboard</div>
		</div>
     
     <p>When you 
     drag a new mainboard to the designer surface, you&#39;ll be prompted, as shown 
	 in the following illustration, to confirm replacement of the mainboard. All 
	 existing connections will be removed. </p>
	 <div class="image">
			<img alt="Replace Mainboard Dialog" title="Replace Mainboard Dialog"src="image013.jpg" />
			<div>
				Replace Mainboard Dialog</div>
		</div>
   
    <p>To continue building our simple example device, open the <strong>Toolbox
	</strong>and drag the modules for this example on to the work canvas. You 
	will need the following modules:</p>
	<ul>
		<li><span class="module">USB Device and Power Supply</span></li>
		<li><span class="module">Button</span></li>
	</ul>
	<p>The Designer Canvas with the modules is shown below.</p>
	<div class="image">
			<img alt="Designer with Modules" title="Designer with Modules"src="image014.jpg" />
			<div>
				Microsoft Visual Studio .NET Gadgeteer Application and Modules</div>
		</div>

<p>As indicated by the instructions in the text box on the canvas, the .NET 
Gadgeteer Designer will graphically connect all the modules for you. Right click 
on the design surface and select <span class="ui">Connect all modules</span>. You can move 
the modules around on the design surface, or move the connections, to make the 
connections easier to read. You can delete any connection by right clicking on 
the connection and selecting <span class="ui">Delete</span>.</p>
<div class="image">
			<img alt="Designer with Module Connections" title="Designer with Module Connections"src="image015.jpg"  />
			<div>
				Microsoft Visual Studio Designer Connected Modules</div>
		</div>
		<p>To manually set a connection, click on a socket in the diagram and 
		hold down the left mouse button. Then you can drag a line that 
		represents the connection from a module socket to a mainboard socket or 
		in the opposite direction from a mainboard to a module. The sockets 
		that the module can use will light up in green, as shown in the 
		following illustration.</p>
<div class="image">
			<img alt="Draw Connection" title="Draw Connection"src="image016.jpg" />
			<div>
				Microsoft Visual Studio Draw Connection</div>
		</div>
		<h3>Designer Documentation Feature</h3>
	<p>The designer also adds a Mainboard and Module documentation feature. This 
	allows the XML documentation for the selected Mainboard or Module to be 
	displayed. To access this feature select the desired module ( or mainboard), 
	by left clicking with the mouse, then press<span class="ui"> F1</span>. The 
	XML documentation for the selected device will be displayed in a Visual 
	Studio window as seen in the illustration below.</p>
   <div class="image">
			<img alt="Designer Documentation" title="Designer Docu,entation"src="image017.jpg"  />
			<div>
				Designer Documentation Feature</div>
		</div>
		<h3>Writing Code for Devices that use .NET Gadgeteer Modules</h3>
	<p>The Designer has allowed us to select the required mainboard and modules, 
	which have then been connected to the desired sockets. The Designer will 
	modify our project application to reflect these settings. To implement the 
	functionality of our simple example, we edit the <span class="code">
	Program.cs</span> file. The following illustration shows the Program.cs file 
	open in Visual Studio.</p>
	<div class="image">
			<img alt="Program.cs" title="Program.cs"src="image018.jpg"  />
			<div>
				Microsoft Visual Studio, New Project, Default Program.cs Code</div>
		</div>
		<p>When using the Designer, the modules are automatically instantiated 
		by auto-generated code. This code can be found in the file Program.Generated.cs, but during normal development it is not necessary to view 
		this file, and this file should not be edited because the Designer will automatically regenerate it and undo any direct changes made to it. The Program.Generated.cs 
		is shown in the following snippet <span class="code">
		Program.Genertaed.cs</span> file.</p>
		<div class="image">
			<img alt="Program.Geberated.cs" title="Program.Geberated.cs"src="image019.jpg"  />
			<div>
				Microsoft Visual Studio, Program.Generated.cs Code</div>
		</div>
		<h4>The Button Pressed event and Delegate Method</h4>
	<p>Next you generate code that will enable the program to react to a button 
	press. To do this, assign an event handler for the <span class="code-member">
	Button.ButtonPressed</span> <strong><i>event. </i></strong> The 
	IntelliSense feature of Visual Studio makes this process very easy.</p>
	<p>In the <span class="code">Program.cs</span> file, after the comment that 
	reads:</p>
	<pre class="code-sample">
 		<span class="code-comment">Initialize event handlers here.</span>
	</pre>
	<p> Type <span class="code">button.</span> (button followed by a period). 
	IntelliSense displays a list of properties, methods and events as shown in 
	the following illustration.</p>
	<div class="image">
			<img alt="Intellisense button class" title="Intellisense button class"src="image020.jpg"  />
			<div>
				IntelliSense Feature Showing Members of the Button class</div>
		</div>
		<p>Using the arrow keys, select <span class="code-member">ButtonPressed.</span> Then type 
		<strong>+=</strong> (plus sign followed by an equals sign). IntelliSense 
		offers an option to automatically insert rest of the declaration:</p>
		<div class="image">
			<img alt="event auto complete" title="event auto complete"src="image021.jpg"  />
			<div>
				IntelliSense Offers to Create the Handler Declaration</div>
		</div>
		<p>Press <strong>TAB</strong> to confirm. IntelliSense offers to automatically generate a delegate method to handle the event.</p>
		<div class="image">
			<img alt="generate handler" title="generate handler"src="image022.jpg"  />
			<div>
				IntelliSense Offers to Generate the Event Handler Method</div>
		</div>
		<p>Press <strong>TAB</strong> to confirm. The following code is generated:</p>
		<div class="image">
			<img alt="generated handler" title="generated handler"src="image023.jpg"  />
			<div>
				Event Handler for the ButtonPressed Event</div>
		</div>
		<p>This event handler will be called each time the button is pressed. 
		Delete the following line from the method:</p>
	<pre class="code-sample">
      <span class="code-keyword">throw new</span> <span class="code-member">NotImplementedException</span>();
    </pre>
    <p>And replace it with:</p>
	<pre class="code-sample">
 		Debug.Print("Button has been Pressed");
	</pre>
	<p>Now when the <span class="module">Button</span> is pressed this debug text string will be written to the debug output.</p>
	<div class="image">
			<img alt="event handler" title="event handler"src="image024.jpg"  />
			<div>
				Output Text string in ButtonPressed Event</div>
		</div>
		<p>The <span class="module">Button</span> module also has an LED. This LED can be configured to automatically react to a Button push, in a number of ways, or can be directly controlled. 
		We are going to use one of the automatic modes, and have the LED 
		illuminated while the Button is pressed and Off when the button is not 
		pressed.</p>
	<p>Go back to the <span class="code-keyword">ProgramStarted</span> method, 
	and below where you added the <span class="code-keyword">
	button.ButtonPressed </span>
	code, add the following line:</p>
	<pre class="code-sample">
      button.LEDMode =
    </pre>
    <p>IntelliSense will then display the  options, select Button.LEDModes 
	as in the following illustration:</p>
	<div class="image">
			<img alt="IntelliSense LEDModes" title="IntelliSense LEDModes"src="image025.jpg"  />
			<div>
				IntelliSense Button.LEDModes</div>
		</div>
		<p>Select the <span class="code-member">Button.LEDModes </span>option from IntelliSense and add a . (period), to have intelliSense display the options for 
		<span class="code-keyword">LEDModes</span>. Select 
		<span class="code-keyword">OnWhilePressed</span>. The following illustration shows the modes.</p>
		<div class="image">
			<img alt="LEDModes value" title="LEDModes value"src="image026.jpg"  />
			<div>
				IntelliSense Button.LEDModes values</div>
		</div>
		<h4>Complete Application Code</h4>
	<p>All the code, for a .NET Gadgeteer Application that writes a debug string 
	when the Button is pressed and lights the LED while the button is pressed, 
	is shown in the following example.</p>
	<div class="image">
			<img alt="Program.cs listing" title="Program.cs listing"src="image027.jpg"  />
			<div>
				Entire Code Listing</div>
		</div>
		<h2 id="deployment">Deploying Your .NET Gadgeteer Application</h2>
		<p>To deploy this application to a mainboard and begin running it, select 
		<span class="ui">Start Debugging</span> from the<span class="ui"> Debug</span> menu, or press 
		<span class="ui">F5.</span></p>
		<div class="image">
			<img alt="Visual Studio Debug" title="Visual Studio Debug"src="image028.jpg"  />
			<div>
				Start Debugging</div>
		</div>
		<p>Make sure the <span class="ui">Output Window </span>is visible by 
		pressing the <span class="ui">CTRL+ALT+O</span> key combination on your 
		keyboard. Alternatively select the<span class="ui"> View</span> tab from 
		the menu and then select <span class="ui">Output</span>. If you have 
		enabled sounds, you should hear Windows make the &quot;USB disconnected&quot; 
		sound as the Mainboard reboots. The <span class="ui">Output Window
		</span>should show the process of loading various files and assemblies. 
		The final line, which appears once the application begins to run, should 
		read <span class="ui">Program Started</span>.</p>
		<div class="image">
			<img alt="Visual Studio program started" title="Visual Studio program started"src="image030.jpg"  />
			<div>
				Output Window - Program Started</div>
		</div>

	<p>If this is the first time a Gadgeteer application has run on the 
	hardware, you might see a message saying <strong>&quot;Updating display 
	configuration....&quot;</strong>This is where the Gadgeeter framework stores 
	some information about your current display into &#39;semi-permanent&#39; storage. 
	If the values are not here, because they have never been written before, 
	then they are written and the mainboard rebooted. You will have to restart 
	the debugger to continue.</p>
	<div class="image">
			<img alt="Display Settings Update" title="Display Settings Update"src="image029.jpg"  />
			<div>
				Display Settings Update - Restart Debugger</div>
		</div>
		<h4>Running the .NET Gadgeteer Device</h4>
	<p>When you see Program Started appear on the Output window, the device is 
	running. You can now press the push button on the Button module. Every time 
	you press the button the debug text string from the event handler will be 
	written to the Output window.. You will also see that the LED lights for the 
	entire time the button is pressed and goes off when the button is released.</p>
	<div class="image">
			<img alt="App running Output Window" title="App running Output Window"src="image031.jpg"  />
			<div>
				Application running - Output Window</div>
		</div>
		<div class="note">
	      <b>Note:</b> The mainboard continues to be programmed, and will run this application whenever it is powered up,
 	       even if it is not connected to a computer.
		</div>
		<p>This was a very simple Gadgeteer Device Application, demonstrating how to connect up modules, use the 
		<span class="ui">Designer</span> and<span class="ui"> Visual Studio</span> to write and deploy your application.</p>
		
		<h2 id="troubleshooting">Troubleshooting</h2>
	<p>This section describes common issues that you may encounter and provides 
	suggestions for how to fix them.</p>
	<h3>Set-up Issues</h3>
	<p>If VS is running when you install GadgeteerCore, you’ll need to close and restart it before creating your first project.  
       Otherwise you won’t see the .NET Gadgeteer Application template.
   </p>
	<p>Sometimes VS will hang at the display: “The debugging target is not in an 
	initialized state; rebooting”. 
	Push the reset button on the mainboard to fix this. 
   </p>
   <h3>USB Device Connection Problems</h3>
	<p>The normal connection channel for deployment and debugging is USB, for 
	this to work your device must be connected and recognised as a USB device. 
	You can test your USB Device connection by following the instructions in <a href="#usbtest">Test your NANO USB Driver Installation</a>.</p>
	<div class="note">
	      <b>Note:</b> If you are "connected" to the device in <span class="ui">MFDeploy</span>,then 
		  <span class="ui">Visual Studio</span> will not find the device. Press 
		  <strong>Disconnect</strong> in <span class="ui">MFDeploy</span> to fix this.&nbsp;
		</div>
		<p>The most common cause of USB connection problems is Power Supply. If you are running of the power from the USB port on your PC then the power 
		is limited to 500mA by the PC. Not all PC's supply a full 5v or 500mA. 
		One solution is to use a &#39;Powered&#39; hub. The other is to use an external 
		power supply. Laptops running from their batteries are a common problem 
		here.</p>
	<p>Sometimes a Power Off/On reset will fix this problem better than a 
	hardware reset using the reset switch.</p>
	<h3>Compile Time Errors</h3>
    <p>If you receive compilation errors when you attempt to deploy and run your application, 
    read the error message carefully. Most errors fall into one of two categories: </p>
    <ul>
 <li>
  <b>Syntax</b>: A statement is missing required syntax, for example, the ending semi-colon character.
  These types of errors are generally reported unambiguously in the Error output window. Fix the syntax problem and try again.
 </li>
 <li>
  <b>Identifier</b>:  An identifier is unknown or invalid. This can happen if you spell the identifier incorrectly, or do not qualify it correctly.
  All  identifiers are case sensitive; for example,
  <span class="code-member">Button</span> cannot be entered as <span class="code-member">button</span>.
  To help avoid problems with identifiers, use the IntelliSense feature of Visual Studio. IntelliSense presents only valid identifiers.
 </li>
</ul>


	<h3>Unexpected Application Behaviour</h3>

<p>
 If your application does not behave as expected (for example, pressing the button does not raise the event),
 start by checking that the physical socket to which the hardware module is connected agrees with the 
 initialization
 in code of the identifier that corresponds to the module.
</p>

<p>
 For example, if you connect a <span class="module">Button</span> to mainboard socket <b>4</b>,
 but initialize it to socket <b>8</b>, the button will not work.
</p>

<pre class="code-sample">
  <span class="code-comment">// Button is actually plugged into socket <b>4</b>.</span>
  button = <span class="code-keyword">new</span> GTM.Sytech.<span class="code-member">Button</span>(8);
</pre>

<p>
 The programming model for the .NET Gadgeteer platform is event driven. Events are raised that correspond to a
 hardware change or physical action. For example, when you press a button, the
 <span class="code-member">ButtonPressed</span> event is raised, and when you release it, the
 <span class="code-member">ButtonReleased</span> event is raised.
</p>

<p>
 You can use debug statements inside your event handlers to make sure that your handler is receiving the event.
 For example, if your LED does not light when you press the button, you can insert a statement inside the event handler
 for the <span class="code-member">ButtonPressed</span> event to make sure that your button is in fact receiving the event.
</p>

<pre class="code-sample">
 <span class="code-keyword">private void</span> button_ButtonPressed(<span class="code-member">Button</span> sender, <span class="code-member">Button.ButtonState</span> state)
 {
    Debug.Print(<span class="code-string">&quot;Button Pressed&quot;</span>);
     
 }
</pre>

<p>
 When you deploy and run your application, check the Visual Studio Debug Output window for your message. 
 If the message does not appear at the expected time (for example, when you press the button), make sure that
 the physical socket and logical initializer are in agreement, as previously described. If they are, the button
 or the module connector cable might be defective. Unplug the mini USB cable from your computer, swap the
 module connector cable or the button with another from your hardware kit, 
 reconnect the mini USB cable, and try again.
</p>

<h3>Deployment</h3>

<p>
 Occasionally, you may receive an error as you attempt to deploy your application to a mainboard. 
 This can happen if the mainboard is not connected to your computer, or the mainboard requires a restart. 
 If the mainboard is disconnected, connect it and retry. If the mainboard is connected when this happens, 
 disconnect it from your computer (by unplugging the mini USB cable), wait a few seconds, and reconnect it.
 Then try the deployment again.
</p> 


 


	



















	</div>
	
	
	</body>

</html>
